    <?php 
        require_once('header_sidebar.php');
        require_once('Class/connexionDB.Class.php');

        $db 			= new connexionDB();
		$unacceptable 	= $db->getUnacceptable();
    ?>
    <script type="text/javascript">
    	var indexRating 		= 0;
    	var indexUnacceptable 	= 0;

    	function addNewRating(idToCopy)
    	{
    		var copied = $('#' + idToCopy).clone();

    		copied.find('#name_level_rating').val('');
    		copied.find('#name_level_rating').attr('name', 'name_level_rating_' + indexRating);
    		copied.find('#name_level_rating').attr('id', 'name_level_rating_' + indexRating);

    		copied.find('#mark_criteria').val('');
    		copied.find('#mark_criteria').attr('name', 'mark_criteria_' + indexRating);
    		copied.find('#mark_criteria').attr('id', 'mark_criteria_' + indexRating);

    		copied.find('#description_level_rating').val('');
    		copied.find('#description_level_rating').attr('name', 'description_level_rating_' + indexRating);
    		copied.find('#description_level_rating').attr('id', 'description_level_rating_' + indexRating);

    		copied.attr('id', idToCopy + '_' + indexRating);
    		copied.insertBefore('#add_level_rating');
    		indexRating++;
    	}

    	function addUnacceptable()
    	{
    		var copied = $('#unacceptable').clone();

    		copied.find('#name_unacceptable').attr('name', 'name_unacceptable_' + indexUnacceptable);
    		copied.find('#name_unacceptable').attr('id', 'name_unacceptable_' + indexUnacceptable);

			copied.find('#mark_unacceptable').attr('name', 'mark_unacceptable_' + indexUnacceptable);
    		copied.find('#mark_unacceptable').attr('id', 'mark_unacceptable_' + indexUnacceptable);

    		copied.find('#description_unacceptable').attr('name', 'description_unacceptable_' + indexUnacceptable);
    		copied.find('#description_unacceptable').attr('id', 'description_unacceptable_' + indexUnacceptable);

    		copied.attr('id', 'unacceptable_' + indexUnacceptable);
    		copied.css('visibility', 'visible');
    		copied.insertBefore('#add_level_rating');
    		indexUnacceptable++;
    	}
    </script>
    <aside class="right-side">
        <section class="content-header">
            <h1>
                <?php echo $translate->translate('HomePageRating'); ?>
                <small><?php echo $translate->translate('CreateRating'); ?></small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> <?php echo $translate->translate('HomePageRating'); ?></a></li>
                <li class="active"><?php echo $translate->translate('CreateRating'); ?></li>
            </ol>
        </section>
        <section class="content">
        	<div class="col-md-6">
        		<div class="box box-info col-md-12	">
                    <div class="box-header col-md-12">
                        <h3 class="box-title">
                        	<?php echo $translate->translate('CreateRatingTitle'); ?>
                        </h3>
                    </div>
                    <div class="box-body">
                    	<div class="form-group">
                            <label for="rating_name"><?php echo $translate->translate('RatingName'); ?></label>
                            <input type="text" class="form-control" id="rating_name" name="rating_name">
                        </div>
                        <div class="box box-info col-md-6">
                        	<div class="box-header">
                            	<h3 class="box-title" id="level_title">
                            		<?php echo $translate->translate('LevelRating'); ?>
                            	</h3>
                            </div>
                            <div class="box-body col-md-12" id="level_rating">
                                <div class="form-group col-md-9">
		                            <label><?php echo $translate->translate('nameLevelRating'); ?></label>
		                            <input type="text" class="form-control" id="name_level_rating" name="name_level_rating">
		                        </div>
		                        <div class="form-group col-md-3">
		                            <label><?php echo $translate->translate('MarkCriteria'); ?></label>
		                            <input type="number" step="any" min="0" class="form-control" id="mark_criteria" name="mark_criteria">
		                        </div>
		                        <div class="form-group col-md-12">
		                            <label><?php echo $translate->translate('DescriptionLevelRating'); ?></label>
		                            <input type="text" class="form-control" id="description_level_rating" name="description_level_rating">
		                        </div>
                            </div>
                            <div class="box-footer col-md-12" id="add_level_rating">
                                <div class="col-md-6" style="display: block; cursor: pointer;" onclick="addNewRating('level_rating');">
                                    <i class="fa fa-fw fa-plus-square-o"></i><i><?php echo $translate->translate('AddLevelRating'); ?></i>
                                </div>
                                <div class="col-md-6" style="display: block; cursor: pointer;" onclick="addUnacceptable();">
                                    <i class="fa fa-fw fa-plus-square-o"></i><i class="text-red"><?php echo $translate->translate('addUnacceptable'); ?></i>
                                </div>
                                <div class="col-md-4 pull-right">
                                	<div class="btn btn-info" onclick=""><?php echo $translate->translate('ValidateLevelRating'); ?></div>
                                </div>
                            </div>
                        </div>
                        <div class="box box-info col-md-6">
                        	<div class="box-header">
                            	<h3 class="box-title" id="criteria_number">Critère #1</h3>
                            </div>
                            <div class="box-body col-md-12">
                                <div class="form-group col-md-9">
		                            <label for="criteria_title"><?php echo $translate->translate('CriteriaTitle'); ?></label>
		                            <input type="text" class="form-control" id="criteria_title" name="criteria_title">
		                        </div>
		                        <div class="form-group col-md-3">
		                            <label for="coefficient"><?php echo $translate->translate('CoefficientTitle'); ?></label>
		                            <input type="number" step="any" min="0" class="form-control" id="coefficient" name="coefficient">
		                        </div>
		                        <div class="form-group col-md-12">
		                            <label for="criteria_description"><?php echo $translate->translate('CriteriaDescription'); ?></label>
		                            <input type="text" class="form-control" id="criteria_description" name="criteria_description">
		                        </div>
                            </div><!-- /.box-body -->
                        </div>
                    </div><!-- /.box-body -->
                </div>
        	</div>	
        </section>
        <div class="box-body col-md-12" id="unacceptable" style="visibility:hidden;">
	        <div class="form-group col-md-9">
	            <label><?php echo $translate->translate('listUnacceptable'); ?></label>
	            <select id="name_unacceptable" class="form-control" name="name_unacceptable">
                    <option selected disabled><?php echo $translate->translate('TitleSelectEvaluationDefault'); ?></option>
                    <?php 

                    	foreach ($unacceptable as $key => $value)
                    	{
                    		echo "<option value='".$value['id']."'>". $value['description'] ."</option>";
                    	}
                    ?>
                </select>
	        </div>
	        <div class="form-group col-md-3">
	            <label><?php echo $translate->translate('MarkCriteria'); ?></label>
	            <input type="number" step="any" min="0" class="form-control" id="mark_unacceptable" name="mark_unacceptable">
	        </div>
	        <div class="form-group col-md-12">
	            <label><?php echo $translate->translate('DescriptionLevelRating'); ?></label>
	            <input type="text" class="form-control" id="description_unacceptable" name="description_unacceptable">
	        </div>
	    </div>
    </aside>
</div>
<?php
    require_once('footer.php');
?>
